package cn.yueranzs.login.service.impl;

import org.springframework.security.web.authentication.WebAuthenticationDetails;

import javax.servlet.http.HttpServletRequest;

/**
 * 描述：自定义WebAuthenticationDetails，将验证码和用户名、密码一同带入AuthenticationProvider中
 * @author yueranzs
 * @date 2021/12/1 9:38
 */
public class LoginWebAuthenticationDetails extends WebAuthenticationDetails {
    private static final long serialVersionUID = 6975601077710753878L;
    /*验证码value*/
    private final String code;
    /*验证码key*/
    private final String randomCode;
    public LoginWebAuthenticationDetails(HttpServletRequest request) {
        super(request);
        code = request.getParameter("code");
        randomCode = request.getParameter("randomCode");
    }

    public String getRandomCode() {
        return randomCode;
    }
    public String getCode() {
        return code;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(super.toString()).append("; code: ").append(this.getCode());
        sb.append(super.toString()).append("; randomCode: ").append(this.getRandomCode());
        return sb.toString();
    }
}
